//==================================================================
//  Copyright (C) 2006  Davide Pasca
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//==================================================================
/// @file	lightmap.h
///
/// Lightmap handling
///
//==================================================================

#ifndef LIGHTMAP_H
#define LIGHTMAP_H

#include "shcube.h"
#include "pmatrix.h"

//==================================================================
class LightMap
{
	static const int FACE_SIZE = 16;	// must be divisible by 4

	PUtils::ImageBase		_color_maps[6];

	PMath::Matrix44		_shlight_mats[3];

	SHCube			_shcube;

public:
	LightMap();
	~LightMap()
	{
	}

	//==================================================================
	void	Update( const PMath::Matrix44 *space_transform_mp );
	void	ResetLights();
	void	DrawLight( const PMath::Vector3 &col, float the, float phi );
	void	DrawLight( const PMath::Vector3 &col, const PMath::Vector4 &dir );

	const PMath::Matrix44	&GetRLightMatrix() const {	return _shlight_mats[0];	}
	const PMath::Matrix44	&GetGLightMatrix() const {	return _shlight_mats[1];	}
	const PMath::Matrix44	&GetBLightMatrix() const {	return _shlight_mats[2];	}
	
	const PMath::Matrix44	*GetRGBLightMatrices() const {	return _shlight_mats;	}

private:
	void	drawPixel( const PMath::Vector3 &col, int face, int x, int y );
};

#endif
